<script setup lang='ts'>
import { onMounted, ref } from 'vue';

const aDom = ref(null) // 1.建立ref对象
const bDom = ref(null) // 1.建立ref对象
onMounted(() => {
    // console.log(aDom.value)
    if (aDom.value) {
        const dom = aDom.value as HTMLAnchorElement
        dom.href = "https://www.qq.com"
    }
    if (bDom.value) {
        const dom = bDom.value as HTMLButtonElement
        dom.onclick = () => {
            alert("这是脱裤子放屁的一种写法")
        }
    }
})
</script>

<template>
    <h1>获取a标签的dom对象</h1>
    <a ref="aDom" href="https://www.baidu.com">百度</a>
    <button ref="bDom">button的按钮</button>
</template>

<style scoped></style>